#!/bin/bash
##############################################################
source ./pkgutils.sh || exit 1
PKG_NAME=$(pkgname); if (( $? != 0)); then exit 2; fi
PKG_VERSION=$(pkgversion); if (( $? != 0)); then exit 3; fi
if [[ $(whoami) != "root" ]]; then
	echo "Please log in as user root...";
	exit 4;
fi
mkdir -pv ./tmp && cd ./tmp || exit 5;
echo "setup of $PKG_NAME $PKG_VERSION";
##############################################################
# do setup tasks (location: /usr/pkg/$PKG_NAME/$PKG_VERSION/tmp)

[[ $(cat /etc/group | grep -v '^#' | grep '^avahi:') != "" ]] || groupadd -fg 84 avahi && \
[[ $(cat /etc/passwd | grep -c '^#' | grep '^avahi:') != "" ]] || useradd -c "Avahi Daemon Owner" -d /var/run/avahi-daemon -u 84 -g avahi -s /bin/false avahi && \
[[ $(cat /etc/group | grep -v '^#' | grep '^netdev:') != "" ]] || groupadd -fg 86 netdev

# hint: write all file modifications/copy/mv/ln into: /usr/pkg/installed.db/${PKG_NAME}_${PKG_VERSION}_pkg.files
##############################################################
ERR=$?;
if (($ERR != 0)); then
    errcho "Aborted package setup with code $ERR";
    exit 6;
fi
